﻿@using Root.Models.Structs
@{
    Layout = "_Layout.cshtml";
    ViewBag.Title = "班级论坛";
    Article main = ViewBag.articleFrom;
}
<script>
    function add(id)
    {
        $.post("/Api/Vote.ashx?AddId=" + id, null, function (data, status)
        {
            if (data == "OK")
            {
                var old = document.getElementById("atc_" + id).innerHTML;
                var newnum = parseInt(old) + 1;
                document.getElementById("atc_" + id).innerHTML = newnum;
                document.getElementById("btn_" + id).disabled = true;
            }
        });
    }
</script>
<div style="text-align:center;margin:0 auto;width:1000px">
    <div style="border: 1px solid; border-radius: 2px; font-size: 120%; ">
        <span>楼主 @main.Name 在  @DateTime.Parse(main.Time).AddHours(ViewBag.time) 时，用着 @main.Location 的IP地址：@main.IP  &nbsp;吐槽道：</span><br />
        <span style="font-size: 120%; color: red;">@Html.Raw(main.Msg)</span><br />
        <span>大家一起来吐槽楼主吧！</span>
    </div>
    <br /><br /><br />
    <table style="margin: 0 auto; width: 1000px">
        @foreach (Article article in ViewBag.articles)
        {
            <tbody>
                <tr>
                    <td class="disdiv" width="200px" style="border: 2px solid; border-radius: 5px; max-width: 200px;vertical-align:top">
                        <hr />
                        <div>
                            <span style="color:blue">@article.Name</span><br />
                            <span>@DateTime.Parse(article.Time).AddHours(ViewBag.time)</span><br />
                            <span>@article.IP</span><br />
                            <span>@article.Location</span>
                        </div>
                        <hr />
                    </td>
                    <td class="disdiv" width="800px" style="border: 2px solid; border-radius: 5px; max-width: 800px">
                        <div style="word-break:break-all;">@Html.Raw(article.Msg.Trim())</div>
                        <hr />
                        <div style="margin-bottom:0px;text-align:right;font-size:80%;">
                            <span>已有 <span id="atc_@article.Id">@article.Count</span> 个赞</span>
                            <input id ="btn_@article.Id" type="button" value="+1" onclick="add(@article.Id)" />
                            &nbsp;&nbsp;&nbsp;
                            <a href="/Articles/Show/@article.Id">显示回复</a>
                            &nbsp;&nbsp;&nbsp;
                        </div>
                    </td>
                </tr>
            </tbody>
        }
    </table>
    <br /><br /><br /><br /><br /><br /><br /><br /><br />
    <script src="/Scripts/ckeditor/ckeditor.js"></script>
    <form method="post" action="/Articles/Add" onsubmit="GetIP()">
        @Html.AntiForgeryToken()
        <div style="margin:0 auto;border:1px dotted">
            <span>姓名：</span><input name="name" type="text" value="@ViewBag.cookie" /><br />
            <textarea rows="80" name="msg" id="articlemsg" style="width:800px;height:600px"></textarea><br />
            <script>CKEDITOR.replace("articlemsg");</script>
            <input type="submit" value="回复" />
        </div>
        <p hidden="hidden" id="keleyivisitorip"></p>
        <input name="ip" type="hidden" id="ip" onload="GetIP()" />
        <input name="pid" type="hidden" value="@ViewBag.pid" />
        <script>GetIP()</script>
    </form>
</div>